package com.shycloud.mido.basic.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.shycloud.mido.basic.api.entity.BasCities;
import com.shycloud.mido.basic.service.BasCitiesService;
import com.shycloud.mido.basic.service.BasProvincesService;
import com.shycloud.mido.common.core.util.R;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *查询省，市
 * @author wsk
 */
@RestController
@AllArgsConstructor
@RequestMapping("/operationCity")
@Api(value = "provinces", description = "运营后台城市模块")
public class OperationCityController {

	private final BasCitiesService basCitiesService;

	private final BasProvincesService basProvincesService;

	/**
	 * 查询省份名称列表
	 * @return 省份名称
	 */
	@GetMapping("/getProvince")
	public R getProvince() {
		return new R<>(basProvincesService.list());
	}

	/**
	 * 通过省份ID查询城市列表
	 * @return 城市名称
	 */
	@GetMapping("/getCity/{provinceid}")
	public R getCity(@PathVariable String provinceid) {
		BasCities basCities = new BasCities();
		basCities.setProvinceid(provinceid);
		return new R<>(basCitiesService.list(Wrappers.query(basCities)));
	}

}
